<include file="Public/head"/>
<body class="no-skin">
<include file="Public/header"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <include file="Public/sidebar"/>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs"/>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set"/>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" id="form" name="form" action="{:u('update')}" method="post">
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 用户组名 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="title" id="title" placeholder="用户组名"
                                           class="col-xs-10 col-sm-5" value="{$group.title}">
                                    <input type="hidden" name="id" id="id" value="{$group.id}">
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle">用户组名称，不能为空。</span>
											</span>
                                </div>
                            </div>
                            <if condition="$group.id neq 1">
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 是否启用 </label>
                                <div class="control-label no-padding-left col-sm-1">
                                    <label>
                                        <input name="status" id="status"
                                        <if condition="$group['status'] eq 1"> checked="checked"</if>
                                        class="ace ace-switch ace-switch-2" type="checkbox" />
                                        <span class="lbl"></span>
                                    </label>
                                </div>
                                <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle">YES，启用；NO，禁用</span>
										</span>
                            </div>
                             <else />
                                <input name="status" id="status" value ="on" type="hidden" />
                             </if>
                            <div class="space-4"></div>
                            
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1">
                                    权限选择 </label>
                                <div class="col-sm-9">
                                    <div class="col-sm-10">
                                        <volist name="rule" id="v">
                                            <div class="row">
                                                <div class="widget-box">
                                                    <div class="widget-header">
                                                        <h4 class="widget-title">
                                                            <label>
                                                                <input name="rules[]"
                                                                       class="ace ace-checkbox-2 father" <?php if(in_array($v['id'],$group['rules'])){echo 'checked="checked"';};?>
                                                                type="checkbox" value="{$v['id']}"/>
                                                                <span class="lbl"> {$v['title']}</span>
                                                            </label>
                                                        </h4>
                                                        <div class="widget-toolbar">
                                                            <notempty name="v.children">
                                                                <a href="#" data-action="collapse">
                                                                    <i class="ace-icon fa fa-chevron-up"></i>
                                                                </a>
                                                            </notempty>
                                                        </div>
                                                    </div>
                                                    <notempty name="v.children">
                                                        <div class="widget-body">
                                                            <div class="widget-main row">
                                                                <volist name="v.children" id="vv">
                                                                    <label class="col-xs-2" style="width:160px;">
                                                                        <input name="rules[]"
                                                                               class="ace ace-checkbox-2 children" <?php if(in_array($vv['id'],$group['rules'])){echo 'checked="checked"';};?>
                                                                        type="checkbox" value="{$vv['id']}"/>
                                                                        <span class="lbl"> {$vv['title']}</span>
                                                                    </label>
                                                                    <volist name="vv.children" id="vvv">
                                                                        <label class="col-xs-2"
                                                                               style="width:160px;">
                                                                            <input name="rules[]"
                                                                                   class="ace ace-checkbox-2 children" <?php if(in_array($vvv['id'],$group['rules'])){echo 'checked="checked"';};?>
                                                                            type="checkbox" value="{$vvv['id']}"/>
                                                                            <span class="lbl"> {$vvv['title']}</span>
                                                                        </label>
                                                                    </volist>
                                                                </volist>
                                                            </div>
                                                        </div>
                                                    </notempty>
                                                </div>
                                            </div>
                                        </volist>
                                    </div>
                                </div>
                            </div>
                            

                            <div class="col-md-offset-2 col-md-9">
                                <button class="btn btn-info submit" type="button">
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </form>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <include file="Public/footer"/>

</div><!-- /.main-container -->

<include file="Public/footerjs"/>
<script src="__PUBLIC__/qwadmin/js/bootbox.js"></script>
<!-- inline scripts related to this page -->
<script type="text/javascript">
    $(".children").click(function () {
        $(this).parent().parent().parent().parent().find(".father").prop("checked", true);
    })
    $(".father").click(function () {
        if (this.checked) {
            $(this).parent().parent().parent().parent().find(".children").prop("checked", true);
        } else {
            $(this).parent().parent().parent().parent().find(".children").prop("checked", false);
        }
    })
    $(".submit").click(function () {
        var title = $("#title").val();
        if (title == '') {
            bootbox.dialog({
                message: "用户组名称不能为空。",
                buttons: {
                    "success": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
            return;
        }
        $('#form').submit();

    })
</script>
</body>
</html>
